package com.codes.core.common.enumtype;

public enum RoleType {


    admin((short)1, "超级管理员"),
    zhuchang((short)2, "审核部"),
    planDept((short)3, "计划部"),
    wuliu((short)4, "物流部"),
    dirver((short)5, "司机"),
    leader((short)6, "总领导"),
    projectLeader((short)7, "项目负责人");



    /** code */
    private short code;

    /** 显示标签 */
    private String label;

    /**
     * 构造器，必须私有
     * @param code
     */
    RoleType(short code, String label){
        this.code = code;
        this.label = label;
    }

    /**
     * 获取code的文本
     * @param code
     * @return
     */
    public static String getLabelByCode (short code){
        for (RoleType enuma : RoleType.values()){
            if (enuma.getCode() == code){
                return enuma.getLabel();
            }
        }
        return "未知枚举项";
    }
    /**
     * 根据文本获取code
     */
    public static short getCodeByLabel(String label){
        for(RoleType enuma : RoleType.values()){
            if(enuma.getLabel().equals(label)){
                return enuma.getCode();
            }
        }
        return -1;

    }

    /**
     * 根据code获取枚举
     */
    public static RoleType getRoleByCode(short code){
        for(RoleType enuma : RoleType.values()){
            if(enuma.getCode() == code){
                return enuma;
            }
        }
        return null;
    }

    public String toString(){
        return label;
    }

    public String getLabel() {
        return label;
    }

    public short getShort(){
        return this.code;
    }

    public short getCode(){
        return this.code;
    }


}
